home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / alib / startup.c < prev   
C/C++ Source or Header  |  1996-10-24  |  2KB  |  79 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: startup.c,v 1.5 1996/10/24 15:50:20 aros Exp $
  4.     $Log: startup.c,v $
  5.     Revision 1.5  1996/10/24 15:50:20  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.4  1996/10/24 01:41:05  aros
  9.     Added __main()
  10.  
  11.     Revision 1.3  1996/10/19 17:02:33  aros
  12.     Added support for malloc() and free(). I added it to the general startup,
  13.     because it uses only a few bytes and with MemHeaders, it would have been
  14.     quite a mess :-) This way, everything is *very* simple.
  15.  
  16.     Revision 1.2  1996/09/17 18:07:19  digulla
  17.     DOSBase and SysBase are now declared in the respective header files.
  18.     The type of DOSBase is "struct DosLibrary *". Fixed everywhere
  19.  
  20.     Revision 1.1  1996/09/17 16:42:45  digulla
  21.     General startup module: Defines two global symbols: SysBase and DOSBase
  22.     and opens dos.library
  23.  
  24.  
  25.     Desc: Common startup code
  26.     Lang: english
  27. */
  28. #include <dos/dos.h>
  29. #include <clib/exec_protos.h>
  30. #include <clib/dos_protos.h>
  31.  
  32. /* Don't define symbols before the entry point. */
  33. extern int main (int argc, char ** argv);
  34. extern APTR __startup_mempool; /* malloc() and free() */
  35.  
  36. AROS_LH0(LONG,entry,struct ExecBase *,sysbase,,)
  37. {
  38.     AROS_LIBFUNC_INIT
  39.     LONG error=RETURN_FAIL;
  40.  
  41.     SysBase=sysbase;
  42.     DOSBase=(struct DosLibrary *)OpenLibrary(DOSNAME,39);
  43.     if(DOSBase!=NULL)
  44.     {
  45.     char * argv[2];
  46.  
  47.     argv[0] = "dummy";
  48.     argv[1] = NULL;
  49.  
  50.     error = main (1, argv);
  51.  
  52.     CloseLibrary((struct Library *)DOSBase);
  53.     }
  54.  
  55.     if (__startup_mempool)
  56.     DeletePool (__startup_mempool);
  57.  
  58.     return error;
  59.     AROS_LIBFUNC_EXIT
  60. }
  61.  
  62. struct ExecBase *SysBase;
  63. struct DosLibrary *DOSBase;
  64.  
  65. APTR __startup_mempool = NULL;
  66.  
  67. /*    Stub function for GCC __main().
  68.  
  69.     The __main() function is originally used for C++ style constructors
  70.     and destructors in C. This replacement does nothing and gets rid of
  71.     linker-errors about references to __main().
  72. */
  73.  
  74. void __main(void)
  75. {
  76. /* Do nothing. */
  77. }
  78.  
  79.